package com.aat.restful.common;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class User implements Serializable {
	private static final long serialVersionUID = 1L;
	private String name;
	private int age;
	private String email;
	private Date ts;

	public User() {
		super();
	}

	public User(String name, int age, String email, Date ts) {
		super();
		this.name = name;
		this.age = age;
		this.email = email;
		this.ts = ts;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Date getTs() {
		return ts;
	}

	public void setTs(Date ts) {
		this.ts = ts;
	}

	public String toString() {
		return "User [name=" + name + ", age=" + age + ", email=" + email + ", ts=" + ts + "]";
	}

	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + age;
		result = prime * result + ((email == null) ? 0 : email.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((ts == null) ? 0 : ts.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (age != other.age)
			return false;
		if (email == null) {
			if (other.email != null)
				return false;
		} else if (!email.equals(other.email))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (ts == null) {
			if (other.ts != null)
				return false;
		} else if (!ts.equals(other.ts))
			return false;
		return true;
	}

	public List<User> getUsers() {
		List<User> lists = new ArrayList<User>();
		lists.add(new User("apple", 22, "apple@test.com", new Date()));
		lists.add(new User("ibm", 32, "ibm@test.com", new Date()));
		lists.add(new User("facebook", 12, "facebook@test.com", new Date()));
		lists.add(new User("sense", 18, "sense@test.com", new Date()));
		lists.add(new User("aat", 6, "aat@test.com", new Date()));
		return lists;
	}

}
